﻿/*----------------------------------------
//Copyright(c) 2013 XXXXXX公司
//版权所有。
//
//文件名：MenuControl.js
//文件功能描述：导航菜单，以及顶部按钮操作Js
// 
//导航菜单，以及顶部按钮操作.JS
//-------------------------------------*/

//初始化页面
$(function () {

    
    window.g_Root_Page = window;

    extendEasyUI();//扩展easyUI组件

    $('#warn').dialog('close');
    $('#CPwd').dialog('close');
    $('#functionTree').tree({
        onClick: function (node) {
            if ($('#functionTree').tree('isLeaf', node.target)) {
                switch (node.text) {
                    case "我的工作":
                        showTab("Workflow/MyWork", node.text);
                        break;
                    case "超期未入库":
                        showTab("Report/EvidenceDeadlineReportView?modeType=0", node.text);
                        break;
                    case "临期未入库":
                        showTab("Report/EvidenceDeadlineReportView?modeType=1", node.text);
                    case "扣押超期":
                        showTab("Report/EvidenceOverDueSeizureReportView?modeType=0", node.text);
                        break;
                    case "扣押临期":
                        showTab("Report/EvidenceOverDueSeizureReportView?modeType=1", node.text);
                        break;
                    case "库存查询":
                        showTab("BaseData/StorageEvidenceListView", node.text);
                        break;
                    case "物品":
                        showTab("Case/EvidenceBillListView", node.text);
                        break;
                    case "入库":
                        showTab("Case/StockBillListView?modeType=0&billType=2", node.text);
                        break;
                    case "调用入库":
                        showTab("Case/StockBillListView?modeType=0&billType=3", node.text);
                        break;
                    case "出库":
                        showTab("Case/StockBillListView?modeType=0&billType=4", node.text);
                        break;
                    case "调用出库":
                        showTab("Case/StockBillListView?modeType=0&billType=5", node.text);
                        break;
                    case "结案":
                        showTab("Case/CloseCaseListView", node.text);
                        break;
                    case "仓储管理":
                        showTab("BaseData/StorageListView", node.text);
                        break;
                    case "物品类型":
                        showTab("BaseData/EvidenceTypeListView", node.text);
                        break;
                    case "系统参数":
                        showTab("System/SystemSettingView", node.text);
                        break;
                    case "角色管理":
                        showTab("System/RoleManageView", node.text);
                        break;
                }
            }
        }
    });  
});
//退出系统
function ExitSys() {
    window.location.href = "/Home/LogOff";
}
//点击左边菜单，打开对应功能页面
function showTab(url, title) {
    var tab = $('#tab');
    if (tab.tabs('exists', title)) {
        tab.tabs('select', title);
    }
    else {
        tab.tabs('add', {
            title: title,
            content: "<iframe  scrolling='yes' frameborder='0' src='/"
                    + url + "' style='width:100%;height:98%;'/>",
            closable: true
        });

    }
}


function ChangePasswordFun() {
    var uId = $("#hUId").val();
    var holdPwd = $("#hold").val();
    var oldPwd = $("#OldPwd").val();
    var newPwd = $("#NewPwd").val();
    var renewPwd = $("#reNewPwd").val();
    if (uId == undefined || uId == "undefined" || uId == "") {
        $.messager.alert("操作提示", "页面过期，请重新登录！", "error");
        window.location.href = "/Home/LogOff";
    }
    if (oldPwd == "" || oldPwd == undefined || oldPwd == "undefined") {
        $.messager.alert("操作提示", "请输入原密码！", "error");
        return;
    }
    if (oldPwd != holdPwd) {
        $.messager.alert("操作提示", "原密码错误！", "error");
        return;
    }
    if (newPwd == "" || newPwd == undefined || newPwd == "undefined") {
        $.messager.alert("操作提示", "请输入新密码！", "error");
        return;
    }
    if (renewPwd == "" || renewPwd == undefined || renewPwd == "undefined") {
        $.messager.alert("操作提示", "请输入确认密码！", "error");
        return;
    }
    if (newPwd != renewPwd) {
        $.messager.alert("操作提示", "两次密码录入不一致，请仔细检查！", "error");
        return;
    }
    var data = { "Id": uId, "Password": renewPwd };
    $.ajax({
        url: "/Home/UpdatePassword",
        type: "POST",
        dataType: "json",
        data: data,
        success: function (req) {
            if (req.IsSuccess) {
                $('#CPwd').dialog('close');
                $.messager.alert("操作提示", req.Message, "info");
                window.location.href = "/Home/LogOff";
            }
            else
                $.messager.alert('操作提示', "密码修改失败！", "error");
        }
    });
};